﻿using GC_FFW.ForecastWriter.Abstractions.Interfaces.Builders;
using GC_FFW.ForecastWriterClient.Abstractions.Interfaces.Factories.ViewModel;
using GC_FFW.ForecastWriterClient.ViewModels;
using GC_FFW.ForecastWriterClient.ViewModels.Parameters;

namespace GC_FFW.ForecastWriterClient.Factories.ViewModel
{
	public class ForecastEditorViewModelFactory : IForecastEditorViewModelFactory
	{
		#region Variables

		private readonly IForecastStructureBuilder _forecastStructureBuilder;
		private readonly IForecastBuilder _forecastBuilder;

		#endregion

		#region Constructors

		public ForecastEditorViewModelFactory(IForecastStructureBuilder forecastStructureBuilder,
			IForecastBuilder forecastBuilder)
		{
			_forecastStructureBuilder = forecastStructureBuilder;
			_forecastBuilder = forecastBuilder;
		}

		#endregion

		#region IForecastEditorViewModelFactory Members

		public ForecastEditorViewModel Create(ForecastEditorViewModelParameters parameters)
		{
			if (parameters != null)
			{
				parameters.ForecastBuilder = _forecastBuilder;
				parameters.ForecastStructureBuilder = _forecastStructureBuilder;
			}

			return new ForecastEditorViewModel(parameters);
		}

		#endregion
	}
}
